/**
 * ===========================================================================
 * File:   msg.h
 * Author: gustavo
 *
 * Created on October 25, 2010, 3:22 PM
 * ---------------------------------------------------------------------------
 *
 *  Copyright (C) 2010  Gustavo Teodoro Laureano - <gustavoengdm@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ===========================================================================
 **/

#ifndef _MSG_H
#define	_MSG_H

#ifdef	__cplusplus
extern "C" {
#endif

	/** Reset the text attributes */
#define MSG_ATTR_RESET		0
	/** Enable the bright text attributes */
#define MSG_ATTR_BRIGHT		1
	/** Enable the dim text attributes */
#define MSG_ATTR_DIM		2
	/** Enable the blink text attributes */
#define MSG_ATTR_BLINK		3
	/** Enable the underline text attributes */
#define MSG_ATTR_UNDERLINE	4
	/** Enable the reverse color text attributes */
#define MSG_ATTR_REVERSE	7
	/** Enable the hidden text attributes */
#define MSG_ATTR_HIDDEN		8
	//    #define MSG_ATTR_UNDEFINED           5
	//    #define MSG_ATTR_UNDEFINED           6

	/** Message color text*/
#define MSG_COLOR_BLACK 	0
#define MSG_COLOR_RED       1
#define MSG_COLOR_GREEN		2
#define MSG_COLOR_YELLOW	3
#define MSG_COLOR_BLUE		4
#define MSG_COLOR_MAGENTA	5
#define MSG_COLOR_CYAN		6
#define MSG_COLOR_GRAY		7
#define MSG_COLOR_WHITE		8  // as background, WHITE means default bg

	/** Default message color text */
#define DEFAULT_FOREGROUND	8
#define DEFAULT_BACKGROUND	8

	/** Returns types */
#define ERROR				0
#define SUCCESS				1
#define WARNING				2

	/** Message type */
#define MSG_ERROR			0
#define MSG_WARNING			1
#define MSG_NOTICE			2

#define MSG_ERROR_MESSAGE	"   [ERROR]: "
#define MSG_WARNING_MESSAGE	" [WARNING]: "
#define MSG_NOTICE_MESSAGE	"  [NOTICE]: "

#define msg_error( format, ... )	msg_print(MSG_ERROR,	"[ %s:%d ] " format, __FILE__, __LINE__, ## __VA_ARGS__)
#define msg_warning( format, ... )	msg_print(MSG_WARNING,	"[ %s:%d ] " format, __FILE__, __LINE__, ## __VA_ARGS__)
#define msg_notice( format, ... )	msg_print(MSG_NOTICE,	"[ %s:%d ] " format, __FILE__, __LINE__, ## __VA_ARGS__)


	void msg_set_message(int type, const char * template, ...);
	void msg_print_message(void);

	/**
	 * @function void msg_set_attributes(int attr, int fg, int bg);
	 * @param attr - text attribute
	 * @param fg - foreground color
	 * @param bg - background color
	 */
	void msg_set_attributes(int attr, int fg, int bg);
	void msg_reset_attributes(void);
	void msg_print_text(const char * template, ...);

	void msg_print(int type, const char * template, ...);
	
	void errno_print(const char * s);
	void errno_exit(const char * s);

#ifdef	__cplusplus
}
#endif

#endif	/* _MSG_H */

